home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utmisc1 / chktex.lha / chktex / WB2Argv.readme < prev   
Text File  |  1996-04-30  |  3KB  |  109 lines

  1. Short:    v1.2. GNU getopt() <-> WBench interface
  2. Author:   <jensthi@ifi.uio.no> (Jens T. Berger Thielemann)
  3. Uploader: <jensthi@ifi.uio.no> (Jens T. Berger Thielemann)
  4. Version:  1.2
  5. Type:     dev/c,dev/cross
  6. Replaces: WB2Argv.lha
  7. Requires: Amiga, C compiler, C= includes, OS 2.04+
  8.  
  9.                              Introduction
  10.                              ~~~~~~~~~~~~
  11.     As  C/C++  is  currently  the only compilable languages worth doing
  12. cross-development  in, I decided to push portability a bit further.  As
  13. many  other  platforms haven't noticed, the computer has a mouse, which
  14. can be utilized for passing options to programs, amongs others.
  15.  
  16.     Still,  as the Workbench is very OS specific; the GNU getopt_long()
  17. routines  are still the programmer's choice if he wishes to easily port
  18. his program.
  19.  
  20.     WB2Argv  is  a  set  of  routines  which  solve this problem.  They
  21. convert  the  tooltypes  and  shift-clicked  icons into an argv similar
  22. array,  which  can be passed directly onto getopt_long().  The getopt()
  23. and  getopt_long() routines are included in the archive.  A minor quirk
  24. is  that  they  require that the Amiga has OS 2.04 or higher.  This may
  25. change if there is enough interest for these routines.
  26.  
  27.     New  for  v1.2  is  that  the routine now uses approx.  1/10 of the
  28. memory  needed  previously.   Cost:  Uses some more stack, but this can
  29. usually be ignored.
  30.  
  31.  
  32.                                 Example
  33.                                 ~~~~~~~
  34.     An  example:   Suppose your program is called "dh1:Tools/Foo".  The
  35. user  shift-clicks  the files "dh1:Data" and "dh1:Neural", and puts the
  36. following arguments as tooltypes:
  37.  
  38. SPEED=FAST
  39. IQ=HIGH
  40.   UNIVERSE=UTOPIA
  41. (FOO=BAR)
  42.  
  43.     The  routine  WB2Argv()  will take the WBenchMsg which is passed to
  44. you,  and  convert  it  to  the following array (line shifts indicating
  45. separate array elements):
  46.  
  47. dh1:Tools/Foo
  48. --speed=FAST
  49. --iq=HIGH
  50. --universe=UTOPIA
  51. --
  52. dh1:Data
  53. dh1:Neural
  54.  
  55.     This  is  fully compliant to the getopt_long() format.  The folding
  56. of  options case can be specified via flags (it stops at the `=' sign).
  57. As  you  see,  the  routine  ignores  options enclosed with parenthesis
  58. around, and skips leading blanks in tooltypes.
  59.  
  60.  
  61.                                    Usage
  62.                                    ~~~~~
  63.     Very  simple.   Put  the  following  chunk  at  the  top of your main()
  64. procedure:
  65.  
  66. --- Cut here ---
  67.  
  68. #include "WB2Argv.h"
  69.  
  70. int main(int argc, char **argv)
  71. {
  72.     int c;
  73.  
  74. #ifdef AMIGA
  75.     if(_WBenchMsg)
  76.     {
  77.         if(argv = WB2Argv(_WBenchMsg, W2A_LOWER))
  78.             argc = CountArgv(argv);
  79.         else
  80.             exit(20);
  81.     }
  82. #endif
  83.  
  84.     /* Your own code */
  85. }
  86.  
  87. --- Cut here ---
  88.  
  89.     As  with  WB2Argv,  the  routines  will only be used and defined if you
  90. define AMIGA somewher.
  91.  
  92.     As  getopt_long(), this is distributed under the GNU General Public
  93. License,  with  the  following  addition:   You  must mention that your
  94. program uses my routine in your document.
  95.  
  96.     Copyright © 1996 Jens T.  Berger Thielemann.
  97.  
  98.     To contact the author for suggestions or whatever, write to:
  99.         Jens Berger
  100.         Spektrumvn. 4
  101.         N-0666 Oslo
  102.         Norway
  103.  
  104.         Email: <jensthi@ifi.uio.no>
  105.  
  106. Note: These routines were written for one of my other projects, ChkTeX,
  107.       which  may  be  useful  if you're doing serious typesetting using
  108.       LaTeX.  Available on AmiNet as text/tex/chktex.lha.
  109.